﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using DTO;

namespace DAO
{
    public class DAO_NguoiQuanTri
    {
        public static List<DTO_NguoiQuanTri> Select_QuanTri_MaQT(string maqt)
        {
            List<DTO_NguoiQuanTri> listqt = new List<DTO_NguoiQuanTri>();
            try
            {
                string s = "Proc_Select_QuanTri_MaQT";
                SqlCommand cmd = new SqlCommand();
                cmd.Connection = ketnoi.Cmb();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = s;
                cmd.Parameters.Add("@MaQT", SqlDbType.NVarChar).Value = maqt;
                SqlDataAdapter da = new SqlDataAdapter();
                da.SelectCommand = cmd;
                DataTable dt = new DataTable();
                da.Fill(dt);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DTO_NguoiQuanTri qt = new DTO_NguoiQuanTri();
                    qt.MaQT = dt.Rows[i]["MaQT"].ToString();
                    qt.TenQT = dt.Rows[i]["TenQT"].ToString();
                    qt.SDT = dt.Rows[i]["SDT"].ToString();
                    qt.GioiTinh = bool.Parse(dt.Rows[i]["GioiTinh"].ToString());
                    qt.Email = dt.Rows[i]["Email"].ToString();
                    qt.DiaChi = dt.Rows[i]["DiaChi"].ToString();
                    qt.NgaySinh = DateTime.Parse(dt.Rows[i]["NgaySinh"].ToString());

                    listqt.Add(qt);
                }
                ketnoi.Cmb().Close();
                return listqt;
            }
            catch (Exception ex)
            {
                return listqt;
            }
        }
    }
}
